<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>聊天界面</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery.easyui.min.js" type="text/javascript"></script>
    <link href="css/easyui.css" rel="stylesheet" type="text/css" />
    <link href="css/icon.css" rel="stylesheet" type="text/css" />
    
    <script language="JavaScript">
	 $.ajax({     
         //要用post方式      
         type: "post",     
         //方法所在页面和方法名      
         url: "<%=request.getContextPath() %>/index/index.action", 
         data: {"vestId":${vestId}}, 
         contentType: "application/x-www-form-urlencoded",     
         dataType: "json",     
         success: function(data) {  
          $.each(data,function(i,item){
 		  var photourl="http://192.168.1.200:8080/download/head_img/photo/"+item.receiverfileUri+"/"+item.receiverphotoname+".jpg";
 		
          $("#ul").append("");	 	 
          $("#ul").append("<li><span><a href=javascript:close('"+item.id+"','"+item.msgId+"')>关闭          </a><a href=javascript:addTab('"+item.trueName+"','<%=request.getContextPath() %>/index/talk.action?name="+item.trueName+":"+item.test+"&fakename="+item.fakeName+"&receiverId="+item.fakeId+"&senderId="+item.trueId+"&senderName="+item.trueName+"&photourl="+photourl+"')>"+item.trueName+"—"+item.fakeName+"</a></span></li>");
          
     	  });
         },     
         error: function(err) {     
         	alert("失败");
         }     
     }); 
   window.setInterval(timeshect, 18000); 
      function timeshect()
      {
    	  $("#ul").html('');
    	  $.ajax({     
	            //要用post方式      
	            type: "post",     
	            //方法所在页面和方法名      
	            url: "<%=request.getContextPath() %>/index/index.action", 
	            data: {"vestId":${vestId}}, 
	            contentType: "application/x-www-form-urlencoded",     
	            dataType: "json",     
	            success: function(data) {  
	            		
	             $.each(data,function(i,item){
	       		  var photourl="http://192.168.1.200:8080/download/head_img/photo/"+item.receiverfileUri+"/"+item.receiverphotoname+".jpg";
	       		  
	            	 $.ajax({     
	                     //要用post方式      
	                     type: "post",     
	                     //方法所在页面和方法名      
	                     url: "<%=request.getContextPath() %>/index/timeshect.action", 
	                     data: {"timesenderId":item.trueId,"timereceiverId":item.fakeId}, 
	                     contentType: "application/x-www-form-urlencoded",     
	                     dataType: "json",     
	                     success: function(data) {  
	                    
	                      if(data.length>=1)
	                    	  {
 
	          	               $("#ul").append("<li><span><a>有  </a><a href=javascript:close('"+item.id+"','"+item.msgId+"')>关闭          </a><a href=javascript:addTab('"+item.trueName+"','<%=request.getContextPath() %>/index/talk.action?name="+item.trueName+":"+item.test+"&fakename="+item.fakeName+"&receiverId="+item.fakeId+"&senderId="+item.trueId+"&senderName="+item.trueName+"&photourl="+photourl+"')>"+item.trueName+"—"+item.fakeName+"</a></span></li>");
	                    	  }else{
	                    		  
		          	            $("#ul").append("<li><span><a href=javascript:close('"+item.id+"','"+item.msgId+"')>关闭          </a><a href=javascript:addTab('"+item.trueName+"','<%=request.getContextPath() %>/index/talk.action?name="+item.trueName+":"+item.test+"&fakename="+item.fakeName+"&receiverId="+item.fakeId+"&senderId="+item.trueId+"&senderName="+item.trueName+"&photourl="+photourl+"')>"+item.trueName+"—"+item.fakeName+"</a></span></li>");

	                    	  }
	                     },     
	                     error: function(err) {     
	                     	alert("失败");
	                     }     
	                 });  
	            	 
	            	 

	             
          	  });
	            },     
	            error: function(err) {     
	            	alert("失败");
	            }     
	        });  
      }
   
     
    	 
    	 function addTab(title, url){
    		
 			if ($('#tt').tabs('exists', title)){
 				$('#tt').tabs('select', title);
 			} else {
 				var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
 				$('#tt').tabs('add',{
 					title:title,
 					content:content,
 					closable:true
 				});
 			}
 		}
    	 function close(ID,msgId)
    	 {
    	 	 $.ajax({     
 	            //要用post方式      
 	            type: "post",     
 	            //方法所在页面和方法名      
 	            url: "<%=request.getContextPath() %>/index/close.action", 
 	            data: {"Id":ID,"msgId":msgId,"vestId":${vestId}}, 
 	            contentType: "application/x-www-form-urlencoded",     
 	            dataType: "json",     
 	            success: function(data) {  
 	            	$("#ul").html('');
			        $("#ul").append("");
 		             $.each(data,function(i,item){ 	 
 			            $("#ul").append("<li><span><a href=javascript:close('"+item.id+"','"+item.msgId+"')>关闭          </a><a href=javascript:addTab('"+item.trueName+"','<%=request.getContextPath() %>/index/talk.action?name="+item.trueName+":"+item.test+"&fakename="+item.fakeName+"')>"+item.trueName+"—"+item.fakeName+"</a></span></li>");	 
 		            	  });
 	            },     
 	            error: function(err) {     
 	            	alert("失败");
 	            }     
 	        }); 
    	
    	 }   
    	 
    </script>
    
     <style>
      body{
		font-size:18px;
		}
        .footer {
            width: 100%;
            text-align: center;
            line-height: 35px;
        }

        .top-bg {
            background-color: #d8e4fe;
            height: 80px;
        }
    </style>
  </head>
  <body class="easyui-layout">  
    <div region="west" split="true" title="" style="width: 200px;">
        <div id="aa" class="easyui-accordion" style="position: absolute; top: 27px; left: 0px; right: 0px; bottom: 0px;">
            <div title="在线好友" iconcls="icon-save" style="overflow: auto; padding: 10px;">
                <ul class="easyui-tree" id="ul">  
                             
                </ul>
            </div>
        </div>
    </div>
    <div id="mainPanle" region="center" style="overflow: hidden;">
        <div id="tt" class="easyui-tabs" fit="true" border="false">
        </div>
    </div>
</body>
</html>



